﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Media;
using MeTalker.Aide.data;

namespace MeTalker.Aide.Forms
{
    internal partial class frmQueryOrder : MeForm
    {
        SoundPlayer player;
        private frmQueryOrder()
        {
            InitializeComponent();
            this.Load += new EventHandler(frmQueryOrder_Load);
            this.FormClosing += new FormClosingEventHandler(frmQueryOrder_FormClosing);
            player = new SoundPlayer(FileFactory.BaseDirectory + "music/notify.wav");
        }

        void frmQueryOrder_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                player.Stop();
                player.Dispose();
                player = null;
            }
            catch { }
        }

        internal frmQueryOrder(string text, int count)
            : this()
        {
            lblMsg.Text = text;
            this.Text += "（您有" + count + "条订单信息）";
        }

       internal void ShowOrder()
        {
            this.Show();
        }

        Point currPoint;
        void frmQueryOrder_Load(object sender, EventArgs e)
        {
            Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height);
            this.PointToScreen(p);
            this.Location = p;
            currPoint = this.Location;
            timer1.Interval = 20;
            timer1.Enabled = true;
            player.Play();
        }
        int height = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            //timer1.Enabled = false;

            //this.Show();
            //for (int i = 0; i <= this.Height; i++)
            //{

            this.Location = new Point(currPoint.X, currPoint.Y - height);
            height++;
            if (height >= this.Height)
            {
                //player.Play();
                timer1.Enabled = false;
            }
            //}
            //timer1.Enabled = true;
        }
    }
}
